home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 11 / AMUG BBS in a Box Volume XI (April 1994) (MacWizards).iso / Files / Tele / Pete Johnson / Flip 1.0.3<source>.sit / WriteMsg.p < prev   
Encoding:
Text File  |  1990-08-18  |  2.3 KB  |  79 lines  |  [TEXT/PJMM]

  1. unit WriteMsg;
  2.  
  3. interface
  4.  
  5.     uses
  6.         FlipGlobals, HelloTabby, TxWrite;
  7.  
  8.     function TwoDigit (Number: integer): str255;
  9.     function TimeStamp (Separator: str255): str255;
  10.     procedure SendMessage (Destination, FromName, TheFile: str255);
  11.  
  12. implementation
  13.  
  14. {-----------------------------------------------------------------    }
  15.  
  16.     function TwoDigit;
  17.  
  18. { Function changes two-digit number to a two-character string.           }
  19.  
  20.     begin
  21.         TwoDigit := concat(StringOf(Number div 10 : 1), StringOf(Number mod 10 : 1))
  22.     end;
  23.  
  24. {-----------------------------------------------------------------    }
  25.  
  26.     function TimeStamp;
  27.  
  28.         var
  29.             DateString, TimeString: str255;
  30.             Today: DateTimeRec;
  31.  
  32.     begin
  33.         GetTime(Today);
  34.  
  35. { The TwoDigit function in the following section turns a two-digit integer          }
  36. { into a two-character string. If there are fewer than two digits, the string    }
  37. { contains a leading '0'.                                                                              }
  38.  
  39.         if Separator = '/' then
  40.             TimeStamp := concat(TwoDigit(Today.Month), '/', TwoDigit(Today.Day), '/', TwoDigit(Today.Year - 1900))
  41.         else
  42.             TimeStamp := concat(TwoDigit(Today.Hour), ':', TwoDigit(Today.Minute), ':', TwoDigit(Today.Second))
  43.     end;
  44.  
  45. {-----------------------------------------------------------------    }
  46.  
  47.     procedure SendMessage;
  48.  
  49.         var
  50.             ConfigRef, GenericRef: integer;
  51.             NodeID: str255;
  52.  
  53.     begin
  54.         Err := FSOpen(':Tabby:Tabby Config', vRefNum, ConfigRef);
  55.         if Err = NoErr then
  56.             Err := ReadALine(ConfigRef, NodeID);
  57.         Err := FSClose(ConfigRef);
  58.         if NodeID[2] = ':' then
  59.             NodeID := copy(NodeID, 3, 255);
  60.         MakeTextFile(concat(GenericPath, 'Generic Export'));
  61.         if Err = NoErr then
  62.             Err := FSOpen(concat(GenericPath, 'Generic Export'), vRefNum, GenericRef);
  63.         if Err = NoErr then
  64.             Err := SetFPos(GenericRef, fsFromLEOF, 0);
  65.         if Err = NoErr then
  66.             Err := WrLn(GenericRef, concat(' M ', ENDLINE, '000', ENDLINE, TimeStamp('/'), ENDLINE, TimeStamp(':')));
  67.         if Err = NoErr then
  68.             Err := WrLn(GenericRef, concat(Destination, ENDLINE, FromName, ENDLINE, 'Sysop'));
  69.         if Err = NoErr then
  70.             Err := WrLn(GenericRef, concat('File ', TheFile));
  71.         if Err = NoErr then
  72.             Err := WrLn(GenericRef, concat(TheFile, ' was sent to you from node ', NodeID, '.'));
  73.         if Err = NoErr then
  74.             Err := WrLn(GenericRef, concat(ENDLINE, '--- Flip ', Version));
  75.         if Err = NoErr then
  76.             Err := WrLn(GenericRef, NULL);
  77.         Err := FSClose(GenericRef)
  78.     end;
  79. end.